package com.seednia.module.core.project.dto;

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.seednia.foundation.framework.dto.AbstractRecord;
import com.seednia.foundation.framework.dto.Constants;
import com.seednia.foundation.framework.dto.ICriteria;
import com.seednia.foundation.framework.util.DateRange;
import com.seednia.foundation.framework.util.IDateRangable;

/**
 * Project Criteria Class to query records
 * 
 * @author Young Suk Ahn
 */
@XmlRootElement(name = "MilestoneCriteria", 
		namespace = "http://seednia.com/core/1.0")
@XmlType(name = "MilestoneCriteria")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class MilestoneCriteria extends MilestoneDto implements ICriteria, IDateRangable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7251718959624630691L;
	private DateRange dateRange = new DateRange();

	public MilestoneCriteria(){
		this.setSid(Constants.SID_ANY);
	}
	
	@Override
	public Date getCreatedBefore() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Date getCreatedAfter() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setSearchText(String value)
	{
		throw new UnsupportedOperationException();
	}

	
	@Override
	public Date getDateFrom() {
		return dateRange.getDateFrom();
	}

	@Override
	public void setDateFrom(Date dtRangeFrom) {
		dateRange.setDateFrom(dtRangeFrom);
	}

	@Override
	public Date getDateTo() {
		return dateRange.getDateTo();
	}

	@Override
	public void setDateTo(Date dtRangeTo) {
		dateRange.setDateTo(dtRangeTo);
	}

	@Override
	public String getDateRangeOf() {
		return dateRange.getDateRangeOf();
	}

	@Override
	public void setDateRangeOf(String dtRangeOf) {
		dateRange.setDateRangeOf(dtRangeOf);
	}

	/**
	 * To create object from JSONP string
	 * Used by the REST framework when sending this object as parameter
	 * @param jsonStr
	 * @return
	 */
	public static MilestoneCriteria fromString(String jsonStr) {
		MilestoneCriteria retval = (MilestoneCriteria) AbstractRecord.fromString(MilestoneCriteria.class, jsonStr);
		return retval;
	}
}
